package gspushmq.v1.produce.job.core;

import com.rabbitmq.client.Connection;

import gspushmq.util.GGLogger;

/**
 *
 * @description rabbitmq链接对象
 * @param
 * @version 1.0
 * @author chengsja
 * @date 2018/12/20 16:14
 *
 */
public enum GGRabbitMQ {

    /**
     *  rabbitmq链接对象
     */
    GG_RABBIT_MQ;

    private Connection connection;

    GGRabbitMQ(Connection connection) {
        this.connection = connection;
    }

    GGRabbitMQ() {

    }

    public void setConnection(Connection connection) {
        this.connection = connection;
    }

    public Connection getConnection() {
        return connection;
    }

    public void destory() {
        try {
            if (this.connection != null && this.connection.isOpen()) {
                this.connection.close();
            }
        } catch (Exception e) {
            GGLogger.error(this.getClass(), e, "关闭GGMessage连接异常");
        }
    }
}
